package com.itheima.d3_charter;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        //1.编码
        String dta = "a我b";
        byte[] bytes = dta.getBytes();
        System.out.println(Arrays.toString(bytes));

        //按照指定字符进行解码
        byte[] byte2 = dta.getBytes("GBK");
        System.out.println(Arrays.toString(byte2));

        //2.解码
        String s1 = new String(bytes);//默认UTF-8解码
        System.out.println(s1);

        String s2 = new String(byte2, "GBK");
        System.out.println(s2);


    }
}
